package org.extreme.pivot;

import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Frame;
import org.apache.pivot.wtk.MenuBar;
import org.apache.pivot.wtk.TabPane;
import org.apache.pivot.wtkx.WTKXSerializer;

public class XDesigner  implements Application {
	Frame frame = null;
	TabPane tabPane = null;
	
	public XDesigner() {
		new DesignerActions(this).init();
	}
	 
    @Override
    public void startup(Display display, Map<String, String> properties) throws Exception {
    	WTKXSerializer wtkxSerializer = new WTKXSerializer();
    	frame = (Frame)wtkxSerializer.readObject(this, "x_designer.wtkx");
    	
        tabPane = (TabPane)wtkxSerializer.get("tabPane");
        
        WTKXSerializer wtkxMenuBarSerializer = new WTKXSerializer();
        
        MenuBar menuBar = (MenuBar)wtkxMenuBarSerializer.readObject(this, "menu_bar.wtkx");
        frame.setMenuBar(menuBar);
        
        frame.open(display);
    }
 
    @Override
    public boolean shutdown(boolean optional) {
        if (frame != null) {
            frame.close();
        }
 
        return false;
    }
 
    @Override
    public void suspend() {
    }
 
    @Override
    public void resume() {
    }
 
    public static void main(String[] args) {
        DesktopApplicationContext.main(XDesigner.class, args);
    }

}
